package dcutils.cards.mtg;

// Import JDK Classes
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

/**
 * Represents all the rarities a card can possibly be in Magic the Gathering.<br/>
 * @author dca
 */
public enum Rarity implements Iterable<Rarity> {
	COMMON("common"),
	UNCOMMON("uncommon"),
	RARE("rare"),
	MYTHIC_RARE("mythic rare");

	/** The name of the rarity type.<br/> */
	private String name;

	/**
	 * The constructor initializes the name of the rarity type.<br/>
	 * @param name The name of the rarity type.<br/>
	 */
	private Rarity(String name) {
		this.name = name;
	} // END constructor

	/**
	 * The getter for the name of the rarity type.<br/>
	 * @return name The name of the rarity type.<br/>
	 */
	public String getName() {
		return this.name;
	} // END getName

	/**
	 * Returns an array of all enum values.<br/>
	 * @return Rarity[] An array of all enum values.<br/>
	 */
	public static Rarity[] asArray() {
		return values();
	} // END asArray

	/**
	 * Returns a list of all enum values.<br/>
	 * @return List<Rarity> A list of all enum values.<br/>
	 */
	public static List<Rarity> asList() {
		return Arrays.asList(asArray());
	} // END asList

	/**
	 * Returns an iterator over all enum values.<br/>
	 * @return Iterator<Rarity> An iterator over all enum values.<br/>
	 */
	@Override
	public Iterator<Rarity> iterator() {
		return asList().iterator();
	} // END iterator

	/**
	 * The getter for the name of the rarity type.<br/>
	 * @return name The name of the rarity type.<br/>
	 */
	@Override
	public String toString() {
		return getName();
	} // END toString
} // END enum Rarity
